using System.Data.Objects;
using Source.Common;

namespace EntityFramework.ServiceLayer
{
    public interface IObjectContextProvider
    {
        /// <summary>
        /// Creates a new ObjectContext instance.
        /// </summary>
        /// <returns></returns>
        IObjectContext Create();
    }

    public class ObjectContextProvider : IObjectContextProvider
    {
        private readonly IConfigurationProvider configurationProvider;

        public ObjectContextProvider(IConfigurationProvider configurationProvider)
        {
            this.configurationProvider = configurationProvider;
        }

        public IObjectContext Create()
        {
            return new Entities(configurationProvider.ConnectionString);
        }
    }
}